package cn.tedu.controller;

import cn.tedu.pojo.Car;
import cn.tedu.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("car")
public class CarController {
    @Autowired//按照数据类型从spring容器中进行匹配
//    @Qualifier("carService")//当容器中值类型相同时按照id值从容器中进行匹配，@Qualifier结合@Autowired一起使用
//    @Resource(name = "carService")// @Resource相当于@Qualifier + @Autowired
    private CarService carService;

    @RequestMapping("get")
    public Car get(){
        return carService.get();

    }
    @RequestMapping("add")
    public void add(Car c){
        carService.add(c);
    }
    @RequestMapping("update")
    public void update(Car c){
        carService.update(c);
    }
}
